import xyz.scoder.*;

public class Test {
    public static void main(String[] args) {
        RemoteControl control = new RemoteControl(3);

        Light light = new Light();
        LightOnCommand onCommand = new LightOnCommand(light);
        LightOffCommand offCommand = new LightOffCommand(light);
        control.setCommand(0, onCommand, offCommand);
        control.onButtonWasPushed(0);
        System.out.println("light state: " + light.getState());
        control.offButtonWasPushed(0);
        System.out.println("light state: " + light.getState());

        Door door = new Door();
        DoorOpenCommand openCommand = new DoorOpenCommand(door);
        DoorCloseCommand closeCommand = new DoorCloseCommand(door);
        control.setCommand(1, openCommand, closeCommand);
        control.onButtonWasPushed(1);
        System.out.println("door state: " + (door.getState() == 1?"开":"关"));
        control.offButtonWasPushed(1);
        System.out.println("door state: " + (door.getState() == 1?"开":"关"));

        Fan fan = new Fan();
        FanHighSpeedCommand highSpeedCommand = new FanHighSpeedCommand(fan);
        FanOffCommand fanOffCommand = new FanOffCommand(fan);
        control.setCommand(2, highSpeedCommand, fanOffCommand);
        control.onButtonWasPushed(2);
        System.out.println("fan speed: " + fan.getSpeed());
        control.offButtonWasPushed(2);
        System.out.println("fan speed: " + fan.getSpeed());
        fan.setSpeed(Fan.MEDIAN);
        System.out.println("fan speed: " + fan.getSpeed());
        control.undoCommand();
        System.out.println("fan speed: " + fan.getSpeed());

        Command[] commands = {onCommand, openCommand, highSpeedCommand};
        MarcoOnCommand marco = new MarcoOnCommand(commands);
        control.setCommand(1, marco, new NoCommand());
        control.onButtonWasPushed(1);
        control.undoCommand();
    }
}
